﻿using Microsoft.Extensions.Logging;
using SqlSugar;

namespace Bigway.Common.Services;

public class SqlLogger(ILogger<SqlLogger> logger)
{
    public void ConfigureLogger(ISqlSugarClient db)
    {
        db.Aop.OnLogExecuting = Log;
    }

    public void Log(string sql, SugarParameter[] parameters)
    {
        var nativeSql = UtilMethods.GetNativeSql(sql, parameters);
        logger.LogInformation("Executing sql {Sql}", nativeSql);
    }
}